#ifndef MAIN_UI_H
#define MAIN_UI_H

#include <QWidget>
#include "HCNG.h"
#include "QSerialPortInfo"
#include "QFile"
#include "QDebug"

QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:



    Widget(QWidget *parent = nullptr);
    ~Widget();

    void MessageHint_slot(QString message);//运行信息输出
    void FrameCommandReceive_slot(quint8 FrameIdentify,quint8 *data,quint32 length);
    bool CreateTabulation(QString FileName);



private slots:

    void on_cScanPort_clicked();//从系统获取端口号

    void on_cOpenSerialPort_clicked();//打开串口

    void on_cCloseSerialPort_clicked();//关闭串口

    void on_cSystemReste_clicked();//系统复位

    void on_cRunDeviceReset_clicked();//恢复出厂设置

    void on_cRunDataSample_clicked();//数据采样

    void on_cRunAddressSet_clicked();//设置地址

    void on_cClearPrintfWindow_clicked();//清空打印窗口

    void on_cRunCalibrationDataLoad_clicked();

    void on_cRunCalibrationDataDelete_clicked();

    void on_cRunCalibrationFileRead_clicked();


    void on_cRunFileTransmit_Request_clicked();

    void on_cRunFileTransmit_clicked();

    void on_cRunClearCalibrationFlie_clicked();

    void on_cRunOneClickSave_clicked();

    void on_cRunCalibrationDataBox_clicked();

    void on_cRunMessageEnable_clicked();

private:

    bool OneClickState;
    typedef struct
    {
        bool enable;//发送使能状态
        quint16 LineNumber;//文件数据行数
        quint16 LineIndex;//行索引值
        quint16 LineNumberResidue;//剩余未发送的行数
        HCNG::FileFormatContent_User_StructDef Content[2000];//下位机最多存储255条
        quint8 buffer[dFrame_LengthMax];//帧发送缓冲区
    }FileTransmitWrite_User0_StructDef;
    Ui::Widget *ui;
    HCNG *hcng;
    FileTransmitWrite_User0_StructDef FileTransmitWrite_user0;//构造函数值会初始化
    void Serial_ReadIPCPort(void);
    uint8_t FileRead_User0(FileTransmitWrite_User0_StructDef &user0);
    bool OneClickSave_Data(quint16 serialnum,float temperature,float concentration,float voltageTemperature,float voltageHydrogen);
signals:

};
#endif // MAIN_UI_H
